﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.IO;

namespace skatesLetsPlayTool
{
    /// <summary>
    /// Serialisierbare Einstellungs-Klasse zum Verwalten von Einstellungen.
    /// </summary>
    [Serializable]
    public class clsSettings
    {

        public String RecordingFolder;
        public String RecordingStartKey;
        public String RecordingStopKey;
        public Boolean ShowRecordingWarnings;
        public String RecordingWarnings;

        public List<String> RecordingSoftware;
        public int SoftwareStartDelayIndex;
        public Boolean MonitorSkype;
        public Boolean MonitorRest;
        public String SkypeName;

        public String ClockProfile;
        public String MarkerShortcut;
        public String MarkerFolder;
        public Boolean MarkerFolderIsRecordingFolder;
        public int MarkerFormatIndex;
        public Boolean AutomaticMarkerSave;

        public Boolean ActivateFileManagement;
        public clsFileManagementSource FileManagment;
        public Boolean WaitAfterStop;
        public int WaitingTimeAfterStop;


        #region "Serialisierung"

        /// <summary>
        /// Speichert alle Einstellungen in die Datei AppPath/settings.xml.
        /// </summary>
        public static void Serialize(clsSettings settings)
        {
            var ser = new XmlSerializer(typeof(clsSettings));

            TextWriter textWriter = new StreamWriter(clsConst.SettingsPath);
            ser.Serialize(textWriter, settings);
            textWriter.Close();
        }

        /// <summary>
        /// Läd alle Einstellungen aus der Settings-Datei in eine Settings-Klasse.
        /// </summary>
        /// <returns>Eine Settings-Klasse mit den Einstellungen aus der settings.xml</returns>
        public static clsSettings DeSerialize()
        {
            var deser = new XmlSerializer(typeof(clsSettings));

            TextReader textReader = new StreamReader(clsConst.SettingsPath);
            var returnValue = (clsSettings)deser.Deserialize(textReader);
            textReader.Close();

            return returnValue;
        }

        #endregion
    }

    
}
